//
//  AdviceFeedBackVC.m
//  XJMCustomer
//
//  Created by Mr.hu on 2017/10/13.
//  Copyright © 2017年 Mr.hu. All rights reserved.
//

#import "AdviceFeedBackVC.h"

@interface AdviceFeedBackVC ()<UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UITextField *InputAdviceText;
@property (weak, nonatomic) IBOutlet UIButton *SubmintAdviceBtn;
@property (weak, nonatomic) IBOutlet UIButton *FirstCheckBtn;
@property (weak, nonatomic) IBOutlet UIButton *SecondCheckBtn;
@property (weak, nonatomic) IBOutlet UIButton *ThreeCheckBtn;
@property (nonatomic,copy)NSString * selectadvice;

@end

@implementation AdviceFeedBackVC

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [[self nextResponder]touchesBegan:touches withEvent:event];
    [super touchesBegan:touches withEvent:event];
    [self.view endEditing:YES];
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addLeftBtn:[UIImage imageNamed:@"fanhui"] Action:@selector(backToPrevious)];
    self.InputAdviceText.delegate = self;
    self.InputAdviceText.keyboardType = UIReturnKeyDone;
    self.title = @"意见反馈";
    
    self.SubmintAdviceBtn.layer.cornerRadius = 22;
    self.SubmintAdviceBtn.layer.masksToBounds = YES;
    
    UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jkr_tapGestureAction:)];
    tapGestureRecognizer.cancelsTouchesInView = NO;
    [self.view addGestureRecognizer:tapGestureRecognizer];
}

- (void)jkr_tapGestureAction:(UITapGestureRecognizer *)tapGusture{
    
    [self.view endEditing:YES];
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    [self.InputAdviceText resignFirstResponder];
    return NO;
}

- (IBAction)AdviceSubmit:(id)sender {
    
    if (_selectadvice == nil) {
        _selectadvice = @"产品问题";
    }
    
    [XJHttpClass teachFeedBackToken:[XJToolClass getToken] type:_selectadvice content:self.InputAdviceText.text andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [XJToolClass tipAnimationWith:errStr];
        }else{
            [self.navigationController popViewControllerAnimated:YES];
            [XJToolClass tipAnimationWith:@"我们会尽快处理您的意见！"];
          }
    }];
}

- (IBAction)SelectCheckAdvice:(UIButton *)sender {
    
    
    if (sender.selected == NO) {
        
        self.selectadvice = @"产品问题";
        [self.FirstCheckBtn setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateNormal];
        [self.SecondCheckBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [self.ThreeCheckBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    }
}

- (IBAction)SecondSelectCheckAdviceMeth:(id)sender {
    if (self.SecondCheckBtn.selected == NO) {
        self.selectadvice = @"投诉";
        [self.FirstCheckBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [self.SecondCheckBtn setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateNormal];
        [self.ThreeCheckBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    }
}

- (IBAction)ThreeSelectCheckAdviceMeth:(id)sender {
    
    if (self.ThreeCheckBtn.selected == NO) {
        self.selectadvice = @"功能闪退";
        [self.FirstCheckBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [self.SecondCheckBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
        [self.ThreeCheckBtn setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateNormal];
    }
}

@end
